#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int hanoi_1(int tall);
void hanoi(int tall, char A, char B, char C);
int main()
{
	int tall;
	scanf("%d", &tall);
	printf("%d\n", hanoi_1(tall));
	hanoi(tall, 'A', 'B', 'C');
	return 0;
}
int hanoi_1(int tall)
{
	int i;
	int sum = 1;
	for (i = 1; i < tall; i++)
		sum *= 2;
	if (tall <= 2)
		return 3;
	return sum + hanoi_1(tall - 1);
}
void hanoi(int tall, char A, char B, char C)
{
	if (tall == 1)
		printf("%c->%c\n", A, C);
	else
	{
		hanoi(tall - 1, A, C, B);
		printf("%c->%c\n", A, C);
		hanoi(tall - 1, B, A, C);
	}
}